package ua.org.extjsbuilder.editors;

import org.eclipse.jface.text.TextAttribute;
import org.eclipse.jface.text.rules.EndOfLineRule;
import org.eclipse.jface.text.rules.IRule;
import org.eclipse.jface.text.rules.IToken;
import org.eclipse.jface.text.rules.MultiLineRule;
import org.eclipse.jface.text.rules.RuleBasedScanner;
import org.eclipse.jface.text.rules.Token;
import org.eclipse.jface.text.rules.WhitespaceRule;

public class JSGeneralScanner extends RuleBasedScanner {

	public JSGeneralScanner(ColorManager manager) {
		IToken comment =
			new Token(
				new TextAttribute(
					manager.getColor(ColorManager.COMMENT)));

		IRule[] rules = new IRule[3];
		//Add rule for comments
		rules[0] = new EndOfLineRule("//", comment);
		rules[1] = new MultiLineRule("/*","*/", comment);
		
		
		// Add generic whitespace rule.
		rules[2] = new WhitespaceRule(new JSWhiteSpaceDetector());
		setRules(rules);
	}

}
